import React, { useEffect, useState } from 'react';
import { Pagination } from "antd";
import * as PublicConfiguration from '@utils/PublicConfiguration'; // 使用 * as 导入整个模块

const ComponentsPagination = ({defaultCurrent = 1, total = 1000, onPaginationChange}) => {
  const [pageSizeOptions, setpageSizeOptions] = useState([]); // 初始化为空数组
  const [pageSize, setpageSize] = useState(PublicConfiguration.limit); // 初始化为空数组
  /**
   * @date: 2024-10-08 16:49:30
   * @functionName:   js
   * @param { Number | page} 当前页面
   * @param { Number | pageSize} 每页条数
   * @description:页码或 pageSize 改变的回调，参数是改变后的页码及每页条数
   * @author: Forever丿顾北
   * @version: V1.0.5
  **/
  const onChange = (page, pageSize) => {
    console.log(page, pageSize);
    setpageSize(pageSize)
    onPaginationChange(page, pageSize)
  };
  useEffect(() => {
    // 更新 pageSizeOptions 的值为从 20 开始的数组
    setpageSizeOptions([10, 20, 40, 60, 80, 100]);
  }, []); // 通过空依赖数组确保只在组件挂载后执行一次
  return (
    <div id='ComponentsPagination'>
      <Pagination
        align="center"
        size='small'
        showQuickJumper
        pageSizeOptions={pageSizeOptions}
        defaultCurrent={defaultCurrent}
        pageSize={pageSize}
        total={total}
        showTotal={(total) => `总共${total}条`}
        onChange={onChange}
      />
    </div>
  );
}
export default ComponentsPagination;